import { request } from 'umi';
import { API } from '../config/requestConfig';
import { parseParams } from '../utils/myUtils';
import { Header } from 'antd/lib/layout/layout';

// 通用请求配置
const commonRequestConfig = {
  headers: {
    'test': 'deng',
  }
};

// login
export function login(payload) {
  const url = `${API}/login`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// getLoginStatus
export function getLoginStatus() {
  const url = `${API}/getLoginStatus`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// logout
export function logout() {
  const url = `${API}/logout`;
  return request(url, {
    method: 'post',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// registered
export function registered(payload) {
  const url = `${API}/registered`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// getAllUser
export function getAllUser() {
  const url = `${API}/getAllUser`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// deleteUser
export function deleteUser(payload) {
  const url = `${API}/deleteUser`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    params: payload,
    credentials: 'include',
    ...commonRequestConfig
  })
}

// getApplyUser
export function getApplyUser() {
  const url = `${API}/getApplyUser`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// passApply
export function passApply(payload) {
  const url = `${API}/passApply`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    params: payload,
    credentials: 'include',
    ...commonRequestConfig
  })
}

// deleteApply
export function deleteApply(payload) {
  const url = `${API}/deleteApply`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    params: payload,
    credentials: 'include',
    ...commonRequestConfig
  })
}

// questionBank
export function getQuestionBank() {
  const url = `${API}/getAllQuestionBank`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function deleteSingleQuestionBank(payload) {
  const url = `${API}/deleteSingleQuestionBank`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function getEachChapterCount() {
  const url = `${API}/getEachChapterCount`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function getEachScoreCount() {
  const url = `${API}/getEachScoreCount`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// questionEdit
export function getAllQuestionLabels() {
  const url = `${API}/getAllQuestionLabels`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function insertSingleQuestionBank(payload) {
  const url = `${API}/insertSingleQuestionBank`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function getQuestionBankById(payload) {
  const url = `${API}/getQuestionBankById`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function updateQuestionBankById(payload) {
  const url = `${API}/updateQuestionBankById`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// questionGenerator
export function questionGen(payload) {
  const url = `${API}/questionGen`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function randomSelect(payload) {
  const url = `${API}/randomSelect`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function geneticSelect(payload) {
  const url = `${API}/geneticSelect`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function downloadFile() {
  const url = `${API}/downloadFile`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// questionGenHistory
export function getAllTestPaperGenHistory() {
  const url = `${API}/getAllTestPaperGenHistory`;
  return request(url, {
    method: 'get',
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function getQuestionGenHistoriesByTestPaperUid(payload) {
  const url = `${API}/getQuestionGenHistoriesByTestPaperUid`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function deleteQuestionGenHistoryByTestPaperUid(payload) {
  const url = `${API}/deleteQuestionGenHistoryByTestPaperUid`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

export function uploadFile(payload) {
  const url = `${API}/uploadFile`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 新 生成word接口
export function questionGen2(payload) {
  const url = `${API}/questionGen2`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 重新导出word接口
export function reExportTestPaper(payload) {
  const url = `${API}/reExportTestPaper`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 导出答案接口
export function exportAnswer(payload) {
  const url = `${API}/exportAnswer`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 获取所有题目类型
export function getTopicType(payload) {
  const url = `${API}/getTopicType`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 搜索题目
export function searchQuestionByTopic(payload) {
  const url = `${API}/searchQuestionByTopic`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 新 更新已经组卷的题目
export function updateQuestionGenHistory(payload) {
  const url = `${API}/updateQuestionGenHistory`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}

// 菜单管理
export function getMenuList(payload) {
  const url = `${API}/menu/page`;
  return request(url, {
    method: 'get',
    params: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}
// 添加菜单
export function addMenu(payload) {
  const url = `${API}/menu/add`;
  return request(url, {
    method: 'post',
    data: payload,
    mode: 'cors',
    credentials: 'include',
    ...commonRequestConfig
  })
}



